import numpy as np
import concurrent.futures


def test_function(a, b):
    return a + b, a * b


if __name__ == '__main__':
    a_range = [i for i in range(5)]
    b_range = [4 for i in range(len(a_range))]

    with concurrent.futures.ProcessPoolExecutor() as executor:
        # map函数会保证函数返回值的顺序
        futures = executor.map(test_function, a_range, b_range)  # 直接返回一个可迭代的对象，使用map函数时不需要显式的进行任务的提交

    # 取出数据
    data = []
    for future in futures:
        data.append(future)

    print(data)

